Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove curve oracle from redemption contract #232

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

0xkorin
Copy link
Collaborator

@0xkorin 0xkorin commented Nov 28, 2023

Previously the YFI price was taken as max(chainlink_price, curve_price), this PR changes it to chainlink_price only

round_id: uint80 = 0
price: int256 = 0
started_at: uint256 = 0
updated_at: uint256 = 0
answered_in_round: uint80 = 0
(round_id, price, started_at, updated_at, answered_in_round) = PRICE_FEED.latestRoundData()
assert updated_at + 3600 > block.timestamp, "price too old"
return price
return convert(price, uint256)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference the price data is sourced from this aggregate contract
https://etherscan.io/address/0x3ebeaca272ce4f60e800f6c5ee678f50d2882fd4#code
That merges this 2 sources to create a YFI/ETH price

  • YFI/USD: 0xA027702dbb89fbd58938e4324ac03B58d812b0E1
  • ETH/USD: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419

@@ -136,13 +136,13 @@ def test_sweep(d_yfi, yfi, redemption, gov):
def test_oracle(project, yfi, d_yfi, ve_yfi, gov):
mock = project.MockOracle.deploy(sender=gov)
redemption = project.Redemption.deploy(
yfi, d_yfi, ve_yfi, gov, mock, mock, 10 * AMOUNT, sender=gov
yfi, d_yfi, ve_yfi, gov, mock, 10 * AMOUNT, sender=gov
Copy link
Contributor

@storming0x storming0x Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since unit tests mostly using the mock oracle and we had the contract live we have some sample data of actual values return

is it to much work to add to ape a fork test using this same account and value and check that return with new contract matches reedem expectations?

since test can be integration only on specific block number, to check how this contract new only CL feed would have behaved against these past trxs

one example
https://etherscan.io/tx/0x51613ef0c083e8c133a2d71fa628db4f4c80c8462e2b5efce05f0f3b0faa9d78

we could use others i guess

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test here that compares the oracle price in the old and new redemption contract, after making sure the old one uses the chainlink price. This should be an equivalent test without having to run a test on an old block, which is (afaik) not very easy to do

Copy link
Contributor

@storming0x storming0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some minor comments, changes overall LGTM

on security i was suggesting if we could add a sort of integration test on this contract against past trxs sample data we have on the previous version to check matching numbers on redeem work as expected

Copy link

@Schlagonia Schlagonia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@storming0x storming0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes and tests LGTM!

@0xkorin
Copy link
Collaborator Author

0xkorin commented Dec 1, 2023

CI is timing out but all tests pass locally:

================================================================================================ test session starts =================================================================================================
platform darwin -- Python 3.11.4, pytest-7.4.3, pluggy-1.3.0
rootdir: .../veYFI
plugins: eth-ape-0.6.26, web3-6.11.4
collected 59 items
INFO: Starting 'anvil' process.
INFO: Connecting to existing Geth node at https://...

tests/functional/test_gauge.py .....                                                                                                                                                                           [  8%]
tests/functional/test_gauge_reward_distribution.py .......                                                                                                                                                     [ 20%]
tests/functional/test_redemption.py ................................                                                                                                                                           [ 74%]
tests/functional/test_ve_yfi_decrease.py ....                                                                                                                                                                  [ 81%]
tests/functional/test_ve_yfi_rewards.py ..                                                                                                                                                                     [ 84%]
tests/functional/test_voting_escrow.py .........                                                                                                                                                               [100%]

=========================================================================================== 59 passed in 322.16s (0:05:22) ===========================================================================================
INFO: Stopping 'anvil' process.

@0xkorin 0xkorin merged commit 229528b into yearn:master Dec 1, 2023
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants